package com.situ.day3;

import org.junit.Test;

import java.util.Scanner;

public class SwitchDemo {

    // Ctrl+Alt+L
    @Test
    public void test1() {
        int num = 3;
        switch (num) {
            case 1:
                System.out.println("1");
                break;
            case 2:
                System.out.println("2");
                break;
            case 3:
                System.out.println("3");
                break;
            default:
                System.out.println("default");
                break;
        }
        System.out.println("----------");
    }

    //    练习：
//    输入月份、年份判断天数：
//    1、3、5、7、8、10、12  -------- 31天
//    4、6 、9、11--------------------30天
//    2----------------------------------28/29天
    @Test
    public void test23() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入月份：");
        int month = scanner.nextInt();
        switch (month) {
            case 1:
                System.out.println("31天");
                break;
            case 2:
                System.out.println("28/29天");
                break;
            case 3:
                System.out.println("31天");
                break;
            case 4:
                System.out.println("30天");
                break;
            case 5:
                System.out.println("31天");
                break;
            case 6:
                System.out.println("30天");
                break;
            default:
                System.out.println("default");
                break;

        }
    }

    @Test
    public void test24() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入月份：");
        int month = scanner.nextInt();
        //卫语句
        if (month < 1 || month > 12) {
            System.out.println("您输入的月份非法");
            return;
        }

        // if   return

        switch (month) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                System.out.println("31天");
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                System.out.println("30天");
                break;
            case 2:
                System.out.println("请输入年份：");
                int year = scanner.nextInt();
                if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
                    System.out.println("29天");
                } else {
                    System.out.println("28天");
                }
                break;
            default:
                System.out.println("default");
                break;
        }
    }

//    1、计算某年是不是闰年：
//    能被4整除，但是不能被100整除
//    ||
//    能被400整除
//    if (() || ())
    @Test
    public void test45() {
        int year = 2023;
        if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
            System.out.println(year + "年是闰年");
        } else {
            System.out.println(year + "年不是闰年");
        }
    }

    //   >=90   <=100   优秀
//   >=80    <90       良好
//   >=70    <80       一般
//   >=60    <70      及格
//   <60                   不及格
    @Test
    public void test453() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入成绩：");
        int score = scanner.nextInt();
        // int num = score / 10;
        switch (score / 10) {
            case 9:
            case 10:
                System.out.println("优秀");
                break;
            case 8:
                System.out.println("良好");
                break;
            case 7:
                System.out.println("一般");
                break;
            case 6:
                System.out.println("及格");
                break;
            default:
                System.out.println("不及格");
                break;
        }
    }

}
